import {defineStore} from 'pinia'
import type { ShopItemData,skuInfo,spuSaleAttrList } from '@/api/detail'
import shopDataApi from '@/api/detail'

interface ShopItemStoreData {
    shopItemList:ShopItemData[],
    skuInfo:skuInfo[],
    spuSaleAttrList:spuSaleAttrList[],

}

export const useShopItemStore = defineStore('shopItem',{
    state():ShopItemStoreData{
        return {
            shopItemList:[],
            skuInfo:[],
            spuSaleAttrList:[]
        }

    },
    actions:{
        async getShopItemList(spuId:number){
            try {
                const result = await shopDataApi.getShopItem(spuId)
                
                this.skuInfo = result.data.skuInfo
                this.spuSaleAttrList = result.data.spuSaleAttrList
            } catch (error) {
                
            }
        }
    },
    getters:{

    }
})